I made this code to select one checkbox when I click on a image but this don't work.
$linkToInterview = 'checkById(document.myform.checkbox,$interview_id)';
?>
<a href="javascript:void(0);" onclick='<?=$linkToInterview?>'><img src="<?=siteConfig::img_dir?>new_photos/video.gif" style="border:0px"/></a>
And Javascript function:
<script type="text/javascript">
function checkByID(chk,id) {
chk[id].checked = true ;
}
</script>
And checkbox code:
<td><input type="checkbox" name="checkbox" value="<?php echo $fet['id']; ?>"
Passerby :
$linkToInterview = 'checkById(document.myform.checkbox,$interview_id)';\n\n\nwill contain literal $interview_id, which means you're outputting\n\n<a href=\"...\" onclick='checkById(document.myform.checkbox,$interview_id)'>\n\n\nTo contain the content of $interview_id, you should use double quote, add a single quote around it, and use double quote on HTML output:\n\n<?php\n$linkToInterview = \"checkById(document.myform.checkbox,'$interview_id')\";\n?>\n<a href=\"...\" onclick=\"<?=$linkToInterview?>;\">\n\n\nThis will output (assuming your $interview_id=\"test\"):\n\n<a href=\"...\" onclick=\"checkById(document.myform.checkbox,'test');\">\n",
2012-10-24T07:53:54